﻿using Bmz.HangFire.Web.Models;
using Bmz.MongoDb;
using Bmz.MongoDb.Repositories;
using Hangfire;
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Bmz.HangFire.Web.Controllers
{
    //http://docs.hangfire.io/en/latest/quick-start.html
    public class HomeController : Controller
    {
        IRepository<CounselorInfo> mongocoll;

        public HomeController()
        {
            mongocoll = new MongoRepository<CounselorInfo>(Settings.Default.MongoDbConnectionString,"UserDB");
        }

        public ActionResult Index()
        {
            var data = mongocoll.GetById(new ObjectId("573457e15a094621405fa6fd"));//.GetAllList();//
            mongocoll.Update(Builders<CounselorInfo>.Filter.Eq(p => p.Id, new ObjectId("573457e15a094621405fa6fd")), Builders<CounselorInfo>.Update.Set(p => p.PersonalDesc, "6666666666"));
            var data1 = mongocoll.GetById(new ObjectId("573457e15a094621405fa6fd"));//.GetAllList();//
            //BackgroundJob.Enqueue(() =>  Debug.Write("Fire-and-forget"));
            //BackgroundJob.Schedule(()=>Console.WriteLine("delayed"),TimeSpan.FromMinutes(1));
            //RecurringJob.AddOrUpdate(()=>Console.WriteLine("daily job"),Cron.Daily);

            //var id = BackgroundJob.Enqueue(()=>Console.WriteLine("Hello ,"));
            //BackgroundJob.ContinueWith(id, () => Console.WriteLine("world!"));

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}